Wednesday, 1 February 2012

LLVM syntax highlighting in Sublime Text 2

If you use a Mac for any kind of development work you should give Sublime Text 2 a try.

It's a seriously awesome editor:
  • It's pretty.
  • It's fast.
  • It supports a good selection of languages.
  • It's got nifty features such as "goto anything" and "auto completion" that you usually only find in full featured IDEs. 
  • As an added bonus it's Australian made. 

Go and download it now!

Seriously :)

One of the languages that Sublime Text 2 doesn't support out of the box is LLVM's assembly language.  (i.e. syntax highlighting doesn't work for .ll files).


Adding LLVM support is really easy because Sublime Text 2 is more or less compatible with TextMate syntax definition files, and an LLVM TextMate bundle is already available on github.

The Sublime Text 2 site has good documentation on how to add new packages. The short story is that you can add LLVM support by doing the following:
  1. Start Sublime Text 2.
  2. Use the "Sublime Text 2/Preferences/Browse Packages" menu to open the packages folder in Finder.
  3. Create a new folder called LLVM (the name isn't really important - use another name if you prefer).
  4. Save llvm.tmbundle from github into your new folder.
Sublime Text 2 will start using the new package without a restart, so go ahead and open an .ll file or two :)